const path = require('path');
const fsExtra = require('fs-extra');
const appRoot = require('app-root-path');

const cfg = {
    port: 8093,
    root: 'boco-sf-zzyf',
    auth: 'boco-sf-zzyf',
    productImgDir: 'productImg',
    activityImgDir: 'activityImg',
    policyCsvExportDir: 'policyCsvExport',
    salesmanCsvExportDir: 'salesmanCsvExport',
    BackupDatabaseDir: 'BackupDatabase',
    customersCsvExportDir: 'customersCsvExportDir',
    //定制任务
    schedules: {
        enable: true,
        jobs: [
            {
                enable: true,
                rule: '0 0 2 * * *',
                fn: 'schedules/clearPolicyCsvFiles.js',
            },
            {
                enable: true,
                rule: '0 5 2 * * *',
                fn: 'schedules/clearSalesmanCsvFiles.js',
            },
            {
                enable: true,
                rule: '0 10 2 * * *',
                fn: 'schedules/BackupDatabase.js',
            },
            {
                enable: true,
                rule: '0 15 2 * * *',
                fn: 'schedules/clearCustomerCsvFiles.js',
            }
        ]
    },
    redis: {
        host: '127.0.0.1',
        port: 6379,
        password: '',
        database: 0,
    },
};
fsExtra.ensureDir(path.join(appRoot.toString(), cfg.productImgDir), err => {
    if (err) {
        process.exit(1);
    }
});
fsExtra.ensureDir(path.join(appRoot.toString(), cfg.activityImgDir), err => {
    if (err) {
        process.exit(1);
    }
});
fsExtra.ensureDir(path.join(appRoot.toString(), cfg.policyCsvExportDir), err => {
    if (err) {
        process.exit(1);
    }
});
fsExtra.ensureDir(path.join(appRoot.toString(), cfg.salesmanCsvExportDir), err => {
    if (err) {
        process.exit(1);
    }
});
fsExtra.ensureDir(path.join(appRoot.toString(), cfg.BackupDatabaseDir), err => {
    if (err) {
        process.exit(1);
    }
});
fsExtra.ensureDir(path.join(appRoot.toString(), cfg.customersCsvExportDir), err => {
    if (err) {
        process.exit(1);
    }
});
module.exports = cfg;
